#include<bits/stdc++.h>
using namespace std;

int mp[10][10];

signed main() {

    mp[1][1] = 6;
    mp[1][2] = 5;
    mp[1][3] = 4;
    mp[1][4] = 3;
    mp[1][5] = 2;
    mp[2][1] = 6;
    mp[2][2] = 5;
    mp[2][3] = 4;
    mp[2][4] = 3;
    mp[2][5] = 1;
    mp[3][1] = 6;
    mp[3][2] = 5;
    mp[3][3] = 4;
    mp[3][4] = 2;
    mp[3][5] = 1;
    mp[4][1] = 6;
    mp[4][2] = 5;
    mp[4][3] = 3;
    mp[4][4] = 2;
    mp[4][5] = 1;
    mp[5][1] = 6;
    mp[5][2] = 4;
    mp[5][3] = 3;
    mp[5][4] = 2;
    mp[5][5] = 1;
    mp[6][1] = 5;
    mp[6][2] = 4;
    mp[6][3] = 3;
    mp[6][4] = 2;
    mp[6][5] = 1;

    int a, b, c, d, e, f, n;
    cin >> a >> b >> c >> d >> e >> f >> n;
    cout << mp[a][n] << " " << mp[b][n] << " " << mp[c][n] << " "  << mp[d][n] << " " << mp[e][n] << " " << mp[f][n];

    return 0;
}

